package org.popupcommunication.service.impl;

import java.util.List;

import org.popupcommunication.dao.MessageDAO;
import org.popupcommunication.model.Message;
import org.popupcommunication.service.MessageManager;
import org.springframework.transaction.annotation.Transactional;


@Transactional
public class MessageManagerBean implements MessageManager{
	
	private MessageDAO messageRepository;

	public MessageDAO getMessageRepository() {
		return messageRepository;
	}

	public void setMessageRepository(MessageDAO mdao) {
		this.messageRepository = mdao;
	}

	@Override
	public List<Message> getAllMessages() {
		return messageRepository.findAll();
	}

	@Override
	public Message findById(int x) {
		return messageRepository.findById(x);
	}

	@Override
	public void update(Message msg) {
		messageRepository.save(msg);		
	}

	@Override
	public Message findByTitle(String name) {
		return messageRepository.findByTitle(name);
	}



}
